<?php
// Start session management and include necessary functions
require_once('../dao/database.php');
require_once('../dao/user_db.php');

// Get the action to perform
if (isset($_GET['ID'])) {
    $ID = $_GET['ID'];
    $action = 'confirm';
} else {
    $action = 'invalide';
}

// Perform the specified action
switch($action) {
    case 'confirm':
        $users = get_user_by_initial_value($ID);
        if (count($users) == 1){
            update_user_confirmed($users[0]);
            header('Location: ../main/index.php?action=confirmed');
        } else {
            $error_message = 'Interner Fehler: Errorcode 0005';
            include('../errors/error.php');
        }
        break;
    case 'invalide':
        exit();
        break;
}
?>